<?
    require_once("mvc/action/ActionForm.php");
    require_once("mvc/action/ActionMessage.php");
    require_once("mvc/action/ActionMessages.php");

    require_once("cms/image/om/TinyImage.php");


    class BaseImageForm extends ActionForm {

        protected $tinyImage;
        protected $formImage;
        protected $path;
        protected $resize;

        public function __construct() {
            $this->tinyImage = new TinyImage();
            $this->formImage = null;
            $this->path = null;
            $this->resize = null;
        }

        public function getTinyImage() {
            return $this->tinyImage;
        }

        public function setTinyImage(TinyImage $tinyImage) {
            $this->tinyImage = $tinyImage;
        }

        public function getFormImage() {
            return $this->formImage;
        }

        public function setFormImage($formImage) {
            $this->formImage = $formImage;
        }

        public function getPath() {
            return $this->path;
        }

        public function setPath($path) {
            $this->path = $path;
        }

        public function getResize() {
            return $this->resize;
        }

        public function setResize($resize) {
            $this->resize = $resize;
        }

        public function validate() {

            $errors = new ActionMessages();

            global $ALLOWABLE_IMAGES;
            if(!is_null($this->getFormImage()) && isset($this->formImage["size"]) && $this->formImage["size"] > 0 && !array_key_exists($this->formImage["type"], $ALLOWABLE_IMAGES))
                $errors->add("formImage",
                    new ActionMessage("errors.image", true, new ActionMessage("prompt.image", true)));

            if(is_null($this->getResize()) || strlen($this->getResize()) == 0)
                $errors->add("resize",
                    new ActionMessage("errors.required", true, new ActionMessage("prompt.resize", true)));


            return $errors;
        }

    }
?>